package cn.com.tiza.spiro.jvm.gc.optimization;

/**
 * Created by TZ0643 on 2015-12-31.
 */
public class PutInEden3 {

    public static final int _10M = 1024 * 1024 * 10;

    public static void main(String[] args) throws InterruptedException {

        Thread.sleep(10000);

        byte[] b1, b2, b3;

        System.out.println("alloc-1 8M...");
        b1 = new byte[_10M * 4 / 5];

        Thread.sleep(10000);
        System.out.println("alloc-2 40M...");

        b2 = new byte[_10M * 4];

        Thread.sleep(10000);
        System.out.println("alloc-3 40M...");

        b3 = new byte[_10M * 4];
        System.out.println("alloc-3 40M lose ref...");
        b3 = null;

        Thread.sleep(10000);
        System.out.println("alloc-4 40M...");

        b3 = new byte[_10M * 4];

        Thread.sleep(10000);
        System.out.println("alloc-5 40M...");

        b3 = new byte[_10M * 4];

        Thread.sleep(10000);
        System.out.println("End...");
        
        /*
        
        java -XX:+UseSerialGC -Xmx200M -Xms200M -Xmn100M -XX:SurvivorRatio=3 -XX:+PrintGCDetails cn.com.tiza.spiro.jvm.gc.optimization.PutInEden2
        
        */
    }
}
